//
//  LBShuangyuTableViewCell.m
//  V-Learn
//
//  Created by Apple on 2019/2/22.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "LBShuangyuTableViewCell.h"
#import "WHC_StackView.h"
#import "UIView+WHC_AutoLayout.h"
#define HorizonGap 15
#define TilteBtnGap 10
#define ColorRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define BRRGBColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]
#define rgb(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
@interface LBShuangyuTableViewCell ()

{
    
    NSArray *_chooseArr;
    
    NSArray *_noChooseArr;
    
}
@end
@implementation  LBShuangyuTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)drawRect:(CGRect)rect
{
//    CGContextRef context=UIGraphicsGetCurrentContext();
//    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
//    CGContextFillRect(context, rect);
//    CGContextSetStrokeColorWithColor(context, ColorRGB(0xf7f7f7).CGColor);
//    CGContextStrokeRect(context, CGRectMake(0, rect.size.height - 0.5, rect.size.width, 0.5));
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle: style reuseIdentifier:reuseIdentifier]) {
        
        [self createCellView];
    }
    
    return self;
}

-(void)createCellView{
    
    self.connentLabel = [[UILabel alloc]init];
    // self.connentLabel.font = FONT(17);
//    self.connentLabel.textColor = [UIColor darkGrayColor];
    self.connentLabel.text = @"016年菲华先生、菲华小姐选拔赛结果当地时间7月31日晚出炉，摘下菲律宾华人小姐后冠的吴茜莉妙答参议员针对“南海仲裁”的提问年仅20岁的王汉民，则在帅哥阵中杀出重围，当选菲华先生。";
    self.connentLabel.textColor = [UIColor clearColor];
    [self.contentView addSubview:self.connentLabel];
//    [self.connentLabel whc_LeftSpace:10 toView:self.contentView];
//    [self.connentLabel whc_TopSpace:5 toView:self.contentView];
//    [self.connentLabel whc_RightSpace:62];
//    [self.connentLabel whc_LeftSpace:50];
//    [self.connentLabel whc_TopSpace:10];
        [self.connentLabel whc_RightSpace:62];
        [self.connentLabel whc_LeftSpace:62];
        [self.connentLabel whc_TopSpace:10];
    [self.connentLabel whc_HeightAuto];
    
    
    
    self.selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:self.selectBtn];
    
    //    [self.selectBtn setImage:[UIImage imageNamed:@"option_n"] forState:UIControlStateNormal];
    //    [self.selectBtn setImage:[UIImage imageNamed:@"option_y"] forState:UIControlStateSelected];
    self.selectBtn.userInteractionEnabled = NO;
    [self.contentView addSubview:self.selectBtn];
//    self.selectBtn.backgroundColor = rgb(233,84,18);
//    [self.selectBtn whc_RightSpace:62];
//    [self.selectBtn whc_BottomSpace:self.connentLabel.bottom];
//    [self.selectBtn whc_BottomSpace:0 toView:self.connentLabel];
//    [self.selectBtn whc_LeftSpace:62];
//    [self.selectBtn whc_TopSpace:10];
    //    [self.selectBtn whc_Size:CGSizeMake(25, 25)];
    [self.selectBtn makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.bottom.top.mas_equalTo(self.connentLabel);
        make.top.mas_equalTo(self.connentLabel.mas_top).mas_equalTo(-5);
        make.bottom.mas_equalTo(self.connentLabel.mas_bottom).mas_equalTo(5);
        make.left.mas_equalTo(self.connentLabel);
        make.right.mas_equalTo(self.connentLabel);
    }];
    [self.selectBtn setLineBreakMode:NSLineBreakByWordWrapping];
    self.selectBtn.layer.cornerRadius = 4;
    self.selectBtn.layer.masksToBounds = YES;
    self.selectBtn.layer.borderWidth = 0.5;
    self.selectBtn.layer.borderColor = rgb(101,101,101).CGColor;
    [self.selectBtn setTitleColor:rgb(101,101,101) forState:UIControlStateNormal];
    self.selectBtn.titleLabel.font = LBFont(16);
//    [self.selectBtn setTitleEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    
}


-(void)UpdateCellWithState:(BOOL)select{
    
    self.selectBtn.selected = select;
    _isSelected = select;
    if (self.selectBtn.selected) {
        self.selectBtn.backgroundColor = rgb(233,84,18);
        [self.selectBtn setTitleColor:rgb(255,255,255)forState:UIControlStateNormal];
//        self.selectBtn.layer.borderWidth = 0.5;
        self.selectBtn.layer.borderColor = rgb(233,84,18).CGColor;
    }else{
        self.selectBtn.backgroundColor = rgb(255,255,255);
        [self.selectBtn setTitleColor:rgb(101,101,101) forState:UIControlStateNormal];
        self.selectBtn.layer.borderWidth = 0.5;
        self.selectBtn.layer.borderColor = rgb(101,101,101).CGColor;
    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
